#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

class Solution {
public:
    string formatString(string str, vector<char>& arg) {
        string str1;
        int i = 0;
        for (int j = 0; j < str.size(); j++) {
            if (str[j] == '%') {
                j++;
                str1 += arg[i++];
            }
            else {
                str1 += str[j];
            }
        }
        for (int j = i; j < arg.size(); j++) {
            str1 += arg[j];
        }

        return str1;
    }
};

void Test1()
{
    string str; int n;
    cin >> str >> n;

    int l = 0, f = l + n - 1;

    int GCsum = 0;
    for (int i = 0; i < str.size() - n; i++)
    {
        int GC = 0;
        for (int j = i; j < i + n; j++)
        {
            if (str[j] == 'G' || str[j] == 'C')
            {
                GC++;
            }
        }
        if (GC > GCsum)
        {
            GCsum = GC;
            l = i;
            f = l + n - 1;
        }
    }

    for (l; l <= f; l++)
    {
        cout << str[l];
    }
}


void Test2()
{
    string str;
    int n;
    queue<char> q;
    int GC = 0, _GC = 0;

    cin >> str >> n;

    int l = 0, r = n - 1;


    for (int i = 0; i < n; i++)
    {
        if (str[i] == 'G' || str[i] == 'C') { GC++; }
        q.push(str[i]);
    }

    _GC = GC;
    for (int i = n; i < str.size(); i++)
    {
        if (q.front() == 'G' || q.front() == 'C') { _GC--; }
        q.pop();
        if (str[i] == 'G' || str[i] == 'C') { _GC++; }
        q.push(str[i]);
        if (_GC > GC)
        {
            GC = _GC;
            l = i - n + 1;
            r = i;
        }
    }

    for (l; l <= r; l++) { cout << str[l]; }
}

int main()
{

    Test2();

	return 0;
}